﻿<?php
require("conexao.php");
if (isset($_GET["acao"])){
$acao = $_GET["acao"];
}else{
$acao = "";
}
if (isset($_GET["id"])){
$id = $_GET["id"];
}else{
$id = "";
}

if ($acao != "") {
$sql = "select c.*, o.* from contaspagarreceber c, comprovantes o where c.idcontas = $id and o.idcontas = $id ";
$resultado = mysql_query ($sql);
$linha = mysql_fetch_array($resultado);

$idclassificacao = $linha["idclassificacao"];
$numero_conta = $linha["numero_conta"];
$idconta = $linha["idconta"];
$data_vcto = $linha["data_vcto"];
$data_pgto = $linha["data_pgto"];
$valor = $linha["valor"];
$descricao = $linha["descricao"];
$situacao = $linha["situacao"];
$comprovante = $linha["comprovante"];
$tipo = $linha["tipo"];

}else{
$idclassificacao = "";
$numero_conta = "";
$idconta = "";
$data_vcto = "";
$data_pgto = "";
$valor = "";
$descricao = "";
$situacao = "";
$comprovante = "";
$tipo = "";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	font-size: 18px;
	font-weight: bold;
}
-->
</style>
<link href="resources/css/jquery.click-calendario-1.0.css" rel="stylesheet" type="text/css"/> 
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.click-calendario-1.0-min.js"></script>		
<script type="text/javascript" src="js/exemplo-calendario.js"></script>
<script src="js/jquery-spin.js"></script>
<script src="js/spin-button.js"></script>
</head>

<body>

<table width="99%" border="0">
  <tr>
    <td><div align="center" class="style1">Conta a Pagar/Receber</div></td>
  </tr>
  <tr>
    <td><form id="form1" name="form1" method="post" enctype="multipart/form-data" action="op_contaspr.php">
      <table width="300" border="1" align="center">
        <tr>
          <td width="74">ID Conta: </td>
          <td width="216"><label>
            <input name="txt_idconta" type="text" id="txt_idconta" size="35" value= "<?php echo $idconta; ?>" />
          </label></td>
        </tr>
        <tr>
          <td width="74">Classificação:</td>
          <td><select name = "txt_idclassificacao" id="txt_idclassificacao">
              <?php
		  $sql_cat = "select * from classificacao order by descricao";
		  $result = mysql_query($sql_cat);
		  
		  while ($registro = mysql_fetch_array($result))
		  {
		  $valor = $registro["idclassificacao"];

		  if ($idclassificacao == $valor)
		  $selecionado = "selected";
		  else
		  $selecionado = "";
		  
		  print "<option value = \"$valor\" $selecionado > $registro[descricao] </option>";
		  }
		  
		  ?>
            </select></td>
        </tr>
        <tr>
          <td width="74">Data de Vencimento:</td>
          <td><input type="text" name="data_1" id="data_1" size="10" maxlength="10" value="<?php echo $data_vcto; ?>"/>          </td>
        </tr>
        <tr>
          <td width="74">Data de Pagamento:</td>
          <td><input type="text" name="data_2" id="data_2" size="10" maxlength="10" value="<?php echo $data_pgto; ?>"/> </td>
        </tr>
        <tr>
          <td><input type="checkbox" name="check-repetir" onclick="document.getElementById('txt_dias').disabled = !this.checked;">Repetir:</td>
          <td><select name="txt_dias" id="txt_dias" disabled="disabled">
          <option value="1">Diário</option>
          <option value="15">Quinzenal</option>
          <option value="30">Mensal</option>
        </select>
            <input type="input" name="txt_repetir" id="spin1" value="1"  /></td>
        </tr>
        <tr>
          <td>Valor:</td>
          <td><input type="input" name="txt_valor" id="spin5" value="0.00" /></td>
        </tr>
        <tr>
          <td>Tipo:</td>
          <td> <select name="txt_tipo" id="txt_tipo">
           <option selected="selected" value="<?php echo $tipo; ?>"><?php echo $tipo; ?></option>
		   <option value=""></option>
           <option value="Saldo">Saldo</option>
           <option value="Débito">Débito</option>
          </select></td>
        </tr>
        <tr>
          <td>Situação:</td>
          <td><select name="txt_situacao" id="txt_situacao">
           <option selected="selected" value="<?php echo $situacao; ?>"><?php echo $situacao; ?></option>
          <option value=""></option>
          <option value="Pago">Pago Parcial</option>
          <option value="Agendado">Agendado</option>
          </select></td>
        </tr>
        <tr>
          <td width="74">Comprovante:</td>
          <?php if ($acao=="") {
		         ?>
          		 <td><input name="comprovante" type="file" id="comprovante" /></td>
				 <?php }else{ ?>
				 <td><input name="txt_comprovante" type="file" id="txt_comprovante" value="<?php echo $comprovante; ?>" />				 </td>
                 
				 <?php } ?>
        </tr>
        <tr>
          <td width="74">Descrição:</td>
          <td><label>
            <textarea name="txt_descricao" id="txt_descricao" cols="35" rows="5"><?php echo $descricao; ?></textarea>
          </label></td>
        </tr>
        <tr>
          <td colspan="2"><label>
              <div align="center">
                <input name="id" type="hidden" value="<?php echo $id; ?>" />
                <input name="acao" type="hidden" value="<?php
				 if ($acao != "") 
				 {echo $acao;
				 } else {
				  echo "cadastrar";
				  } ?>" />
                <input type="submit" name="Submit" value="<?php
				 if ($acao != "") 
				 {echo $acao;
				 } else {
				  echo "cadastrar";
				  } ?>" />
                  <input type="button" value="Voltar" onclick=javascript:window.history.back()>
              </div>
            </label></td>
        </tr>
      </table>
    </form></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>

</body>
</html>
